package correct.day13;

public class Test2 {
    public static void main(String[] args) {
        int[] arr = {2,2,3,4,8,99,9,34};
        int[] hash = new int[100010];
        int left = 0, right = 0, n = arr.length;
        int ret = 0;
        while(right < n)
        {
            hash[arr[right]]++; // 进窗⼝
            while(hash[arr[right]] > 1) // 判断
            {
                // 出窗⼝
                hash[arr[left]]--;
                left++;
            }
            ret = Math.max(ret, right - left + 1); // 更新结果
            right++;
        }
        System.out.println(ret);
    }
}
